package com.tt.lcd.qunyangGPRS.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.tt.lcd.qunyangGPRS.R;
import com.tt.lcd.qunyangGPRS.dao.DataManager;

import java.util.HashMap;
import java.util.List;

public class SiweizhanXuanze extends Activity {
	private String date;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.siweizhan_xuanze);
		ListView listView = (ListView) this.findViewById(R.id.siweizhan_list);

		Intent it = getIntent();

		this.date = it.getExtras().getString("date");
		//获取到集合数据
		List<HashMap<String, Object>> data = new DataManager(this).getZhanInfo(date);
		SimpleAdapter adapter = new SimpleAdapter(this, data, R.layout.siweizhan_listview,
				new String[]{"zhanId", "muzhu_shuliang"}, new int[]{R.id.zhanID, R.id.muzhu_shuliang});
		//实现列表的显示
		listView.setAdapter(adapter);
		//条目点击事件
		listView.setOnItemClickListener(new ItemClickListener());

	}

	private final class ItemClickListener implements OnItemClickListener{

		public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
			ListView listView = (ListView) parent;
			HashMap<String, Object> data = (HashMap<String, Object>)
					listView.getItemAtPosition(position);

			String zhanId = data.get("zhanId").toString();

			Intent it = new Intent();
			it.setClass(SiweizhanXuanze.this, Dantai_info.class);
//			 
//			 Bundle bundle = new Bundle();
//			 bundle.putString("zhanId", date);
//			 it.putExtras(bundle);
			it.putExtra("zhanId", zhanId);
			it.putExtra("date", date);
			startActivity(it);
		}

	}

}
